Decreases in computer prices have resulted in many households and businesses having at least one computer. In fact, many households and businesses have more than one computer, wherein the computers comprise many of the same programs. These computers are typically logically connected, creating a logical network wherein data may be shared between computers. Various languages, or programs, are used between networked computers. One such language is Java, developed by Sun Microsystems. Java is a high-level programming language that is object-oriented, yet simple enough to eliminate language features that cause common programming errors. Java source code files are compiled into a format called bytecode, which can then be executed by a Java interpreter. Compiled Java code can run on most computers because Java interpreters and runtime environments, known as Java Virtual Machines (VMs), exist for most operating systems, including, but not limited to, UNIX, the Macintosh OS, and Windows.
A Java remote method invocation (RMI) application programming interface (API) allows an object running in one VM to invoke methods on an object running in another VM. Distributed applications, such as RMI, are often comprised of two or more tiers, namely, a server application tier, a client application tier, and sometimes, one or more middle tiers. A typical server application creates remote objects, makes references to the objects accessible, and waits for client applications to invoke methods on these remote objects. A typical client application obtains a remote reference to one or more remote objects in the server application and then invokes methods on the objects. RMI provides the mechanism by which the server application and the client application communicate and pass information back and forth. Such an application is sometimes referred to as a distributed object application. Therefore, RMI provides for remote communication, from the client application to the server application, or vice versa, between programs written in the Java programming language.
While both the client application and the server application may be located on the same computer, typical distributed applications provide the client application and the server application on separate networked computers. Communication between the computers within the network, or within the same computer, is typically performed through the use of sockets. A socket is a software channel, or object, through which applications can connect with each other and communicate. In fact, one of the most direct ways of communicating between different application components is to use sockets. The use of sockets simplifies program development because the programmer need only focus on manipulating the socket and can rely on the operating system to actually transport messages across the network correctly.
With the use of sockets, a client computer (one having the client application therein) and a server computer (one having the server application therein) are logically connected for the exchange of data. Specifically, the client application initiates a connection with the server application, while the server application waits for the client application to initiate the connection. In order for the two computers to communicate effectively, it is often necessary that they each implement a mutually acceptable application protocol (e.g., RMI).
Each computer within the network is identified by an address. Within transmission control protocol/Internet protocol (TCP/IP) networking, as is typical of most networks, the address refers to an Internet protocol (IP) address, such as, for example, 123.456.7.8. Separate from the IP address that specifies a particular computer, each computer has a number of ports that allow the handling of multiple connections simultaneously.
A first application within a first computer, that wishes to receive a connection from a second application within a second computer, typically asks an operating system within the first computer to create a socket and bind it to a port. The first application, after creating the socket, waits and listens on the socket it has created to receive incoming connections. The second application also creates a socket for communicating with the first application, or receiver. The first computer specifies the IP address and the port number of the receiving end. Thereafter, the two programs establish a communication through the network using respective sockets. The two programs may then exchange information, each by writing to and reading from the corresponding sockets.
RMI is run on most VMs and typically handles socket generation requests that are executed by an operating system. In addition, RMI handles socket manipulation after the operating system has opened a socket, as well as determining whether new sockets must be opened or whether an unused socket may be used for an application. Unfortunately, if an established socket is not used after a certain amount of time, RMI closes the socket. As known in the art, socket closure is performed to decrease the excessive use of system resources that are required to maintain a socket. Examples of such resources include, but are not limited to, memory and processor allocation.
One way to prevent socket closure is to send a “keep alive” message (i.e.: ping) from the client to the server or, from the server to the client. Unfortunately, this method of maintaining a socket is costly to bandwidth since “keep alive” messages are constantly being transmitted. Further, the management of “keep alive” messages is demanding on memory resources and on the server processor since the reception of such messages by the server requires processing.
Therefore, the creation and management of sockets is important in providing an efficient computer network.